//
//  cin001.cpp
//  cpp_learn
//
//  Created by 李贺 on 2021/12/13.
//

#include "cin001.hpp"

namespace cin_001 {
    void test_cin_001() {
        cout << "请输入姓名和爱好" << endl;
        string name, like;
        cin >> name;
        cin >> like;
        cout << "name==" << name << ",like==" << like << endl;
    }

void test_ref() {
    int val = 1;
    int &ref1 = val;
    int &ref2 = ref1;
    int val2 = ref2;
    cout << val2 << endl;
}
void test_pointer() {
    int val1 = 0x99;
    int *p = &val1;
    cout << *p << endl;
    
    int **p1 = &p;
    /** 1: 解指针两次才能取到 val1的值;
        2: 指针存储的是某个变量的内存地址,指针自己的内存地址另外有地方存储着
    */
    cout << **p1 << endl;
    cout << &p << endl;
    cout << *p1 << endl;
}

void test_const_pointer() {
    int val = 99;
    const int &fuck = val;
    const int *pre = &fuck;
    cout << *pre << endl;
    
    const double val2 = 88.88;
    const double val3 = 99.99;
    const double  * const pre1 = &val2;
    //    pre1 = &val3; 这个不支持,因为是pre1是指向常量类型的常量指针
    cout << *pre1 << endl;
}

void test_typedef_demo() {
    typedef double fuck_double;
    typedef fuck_double base, *p;
    base val = 999.9;
    p pre = &val;
    fuck_double nimei = 999.99;
    cout << *pre << endl;
    
}

void test_string() {
    string s1 = "what the fuck";
    for (decltype(s1.size()) index = 0; index < s1.size(); index++) {
        s1[index] = toupper(s1[index]);
    }
    
    cout << s1 << endl;
    
    for(auto c: s1) {
        cout << c << endl;
    }
    
}

}



